package com.example.gw_back_end.service.provider;

import com.example.gw_back_end.domain.PageResult;
import com.example.gw_back_end.domain.SearchParams;
import com.example.gw_back_end.domain.entities.Category;
import com.example.gw_back_end.service.*;
import org.springframework.stereotype.Service;

@Service
public class SearchService {
    private final UserService userService;
    private final PostService postService;
    private final GameService gameService;
    private final CategoryService categoryService;

    public SearchService(UserService userService, PostService postService, GameService gameService, CategoryService categoryService) {
        this.userService = userService;
        this.postService = postService;
        this.gameService = gameService;
        this.categoryService = categoryService;
    }

    public PageResult search(SearchParams searchParams) {
        Integer type = searchParams.getType();
        return switch (type) {
//            case 0 -> null;
            case 1 -> userService.searchUser(searchParams);
            case 2 -> gameService.searchGame(searchParams);
            case 3 -> postService.searchPost(searchParams);
            case 4 -> categoryService.searchCategory(searchParams);
            default -> null;
        };
    }
}
